using Sirenix.OdinInspector;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class MaskFloating : Floating, IPointerClickHandler
{
    bool _isTransparent;
    [ShowInInspector]
    public bool IsTranparent
    {
        get => _isTransparent;
        set
        {
            _isTransparent = value;
            this.SetDirty();
        }
    }

    protected override void Refresh()
    {
        this.RefreshTransparent();
    }

    void RefreshTransparent()
    {
        if(this.IsTranparent)
        {
            this.GetComponent<CanvasGroup>().alpha = 0;
        }
        else
        {
            this.GetComponent<CanvasGroup>().alpha = 1;
        }
    }

    public void OnPointerClick(PointerEventData eventData)
    {
        var page = UIEngine.Stuff.Top;
        if(page.clickMaskToBack)
        {
            UIEngine.Stuff.Back();
        }
    }
}
